package cqut.test3;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
import java.util.*;
public class CompareDate {
    public static void main(String args[ ]) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输⼊第⼀个年，⽉，⽇数据");
        System.out.print("输⼊年份");
        short yearOne = scanner.nextShort();
        System.out.print("输⼊⽉份");
        byte monthOne = scanner.nextByte();
        System.out.print("输⼊⽇期");
        byte dayOne = scanner.nextByte();
        System.out.println("输⼊第⼆个年，⽉，⽇数据");
        System.out.print("输⼊年份");
        short yearTwo = scanner.nextShort();
        System.out.print("输⼊⽉份");
        byte monthTwo= scanner.nextByte();
        System.out.print("输⼊⽇期");
        byte dayTwo = scanner.nextByte();
        Calendar calendar =Calendar.getInstance();
        calendar.set(Calendar.YEAR,yearOne);
        calendar.set(Calendar.MONTH,monthOne-1);
        calendar.set(Calendar.DAY_OF_MONTH,dayOne);
        long timeOne =calendar.getTimeInMillis();
        calendar.set(yearTwo,monthTwo-1,dayTwo);
        long timeTwo=calendar.getTimeInMillis();
        Date date1 = new Date((timeOne));
        Date date2 =new Date(timeTwo);
        if(date2.equals(date1))
            System.out.println("两个⽇期的年、⽉、⽇完全相同");
        else if(date2.after(date1))
            System.out.println("您输⼊的第⼆个⽇期⼤于第⼀个⽇期");
        else if(date2.before(date1))
            System.out.println("您输⼊的第⼆个⽇期⼩于第⼀个⽇期");
       long days= dayOne-dayTwo;
        System.out.println(yearOne+"年"+monthOne+"⽉"+dayOne+"⽇和"
                +yearTwo+"年"+monthTwo+"⽉"+dayTwo+"相隔"+days+"天");
    }
}

